﻿using Microsoft.AspNetCore.Mvc;
using SportsPlatform.Dto.SportBusiness.Category;
using SportsPlatform.SportBusiness.ISportBusiness;
using SportsPlatform.Base;
using SportsPlatform.Query.SportBusiness.Category;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SportsPlatform.Filters;
using SportsPlatform.Enums;
using SportsPlatform.Application.SportBusiness.ISportBusiness;
using SportsPlatform.Application.Dto.Home;
using Microsoft.AspNetCore.Authorization;
using SportsPlatform.Application.Query.Home;

namespace SportsPlatform.Controllers
{
    /// <summary>
    /// 首页控制器
    /// </summary>
    [ActionAuthorization]
    [Route("api/[controller]/[action]")]
    public class IndexController : SportsPlatformControllerBase
    {

        /// <summary>
        /// 首页服务接口
        /// </summary>
        private readonly IHomService _homService;

        public IndexController(IHomService service)
        {
            this._homService = service;
        }

        /// <summary>
        /// 获取待审核的客户信息总数
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultDto<int>> GetPendingInfoCount()
        {
            return await _homService.GetPendingInfoCount();
        }

        /// <summary>
        /// 获取今日累计注册用户
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultDto<RegisterUsersDto>> GetAccumulativeRegistrUsersToDay()
        {
            return await _homService.GetAccumulativeRegistrUsersToDay();
        }

        /// <summary>
        /// 获取累计注册用户数量
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultDto<RegisterUsersDto>> GetAccumulativeRegistrUsers()
        {
            return await _homService.GetAccumulativeRegistrUsers();
        }

        /// <summary>
        /// 获取累计赛事总条数和同比昨日百分比
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultDto<AccumulativeCompetitionDto>> GetAccumulativeCompetitionCount()
        {
            return await _homService.GetAccumulativeCompetitionCount();
        }

        /// <summary>
        /// 获取今日新增赛事条数和同比昨日百分比
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultDto<AccumulativeCompetitionDto>> GetAccumulativeCompetitionToDayCount()
        {
            return await _homService.GetAccumulativeCompetitionToDayCount();
        }

        /// <summary>
        /// 获取预警信息列表
        /// </summary>
        /// <param name="query"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PagePagingDto<WarningListDto>> GetWarningList([FromBody] BasePageQuery query)
        {
            return await _homService.GetWarningList(query);
        }

        /// <summary>
        /// 获取新增用户趋势
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultDto<Dictionary<string, int>>> GetAddUserTendency([FromBody] GetAddUserQuery query)
        {
            return await _homService.GetAddUserTendency(query);
        }

        /// <summary>
        /// 获取今日比赛场次
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultDto<ToDayCompetitionDto>> GetToDayCompetition()
        {
            return await _homService.GetToDayCompetition();
        }

        /// <summary>
        /// 获取今日报名用户
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultDto<ToDayRegiisterInfoDto>> GetToDayRegiisterInfo()
        {
            return await _homService.GetToDayRegiisterInfo();
        }

        /// <summary>
        /// 获取今日比赛用户
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public async Task<ResultDto<ToDayGameoUserDto>> GetToDayGameoUser()
        {
            return await _homService.GetToDayGameoUser();
        }
    }
}

